package leetcode.weekly.week315;

import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;

//Solution1Test
public class Solution1 {

	public int findMaxK(int[] nums) {
		int ans = -1;
		Set<Integer> set = new HashSet<>();
		Arrays.sort(nums);
		for (int num : nums) {
			if (num < 0) {
				set.add(num);
			} else {
				if (set.contains(-num) && num > ans) {
					ans = num;
				}
			}
		}
		return ans;
	}
}
